package cn.edu.buu.news.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
public class RedisTokenClean implements ApplicationListener<ContextClosedEvent> {
    @Autowired
    private RedisTemplate redisTemplate;
    @Override
    public void onApplicationEvent(ContextClosedEvent event) {
        Set keys = redisTemplate.keys( "news:admin:*");
        redisTemplate.delete(keys);
    }
}
